/**
 * 
 */
package neptune.web.server.operations;

import it.robertobifulco.ias.IncorrectParamsException;
import it.robertobifulco.ias.Operation;
import neptune.manager.NeptuneManager;
import neptune.manager.model.experiment.Experiment;
import neptune.web.server.ApplicationManager;
import neptune.web.server.Debug;

/**
 * @author Roberto Bifulco [info@robertobifulco.it, robertobifulco.it]
 * 
 */
public class GetExperiment implements Operation {

	public static String ID = "GetExperiment";

	/*
	 * (non-Javadoc)
	 * 
	 * @see it.robertobifulco.ias.Operation#execute(java.lang.Object[])
	 */
	/**
	 * 
	 * @param args
	 *            [0] = String expId
	 * @return Experiment
	 */
	public Object[] execute(Object[] args) throws IncorrectParamsException,
			Exception {

		try {
			String expId = (String) args[0];

			NeptuneManager expManager = ApplicationManager
					.getApplicationManager().getNeptuneManager();

			Experiment exp = expManager.getExperiment(expId);

			return new Object[] { exp };
		} catch (Exception e) {
			Debug.printTrace(e);
			throw new Exception(e);
		}

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see it.robertobifulco.ias.Operation#getDescription()
	 */
	public String getDescription() {
		return "Gets informations regarding one experiment";
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see it.robertobifulco.ias.Operation#getID()
	 */
	public String getID() {
		return ID;
	}

}
